package cn.zust.ly.EyExample.Ez48;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[][] = new int[n+1][n+1];
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            a[x][y] = 1;
            a[y][x] = -1;
        }
        for (int k = 0; k < n; k++) {
            for (int j = 1; j < n+1; j++) {
                for (int i = 1; i < n+1; i++) {
                    if (a[j][i] != 0) {
                        if (k+1 == j) {
                            System.out.print(a[j][i]);
                        } else {
                            System.out.print("0");
                        }
                    }
                }
                System.out.print("\n");
            }
        }

    }
}
